const state = {
  isCollapse: false, // 控制侧边导航栏展开收起
  selectMenu: [] // 记录访问过的侧边栏数据
}

const mutations = {
  collapseMenu(state) {
    state.isCollapse = !state.isCollapse
  },
  addMenu(state, payload) {
    if (state.selectMenu.findIndex(item => item.path === payload.path) === -1)
      state.selectMenu.push(payload)
  },
  closeMenu(state, payload) {
    const index = state.selectMenu.findIndex(item => item.path === payload.path)
    state.selectMenu.splice(index, 1)
  }
}

export default {
  state,
  mutations
}
